﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Linq;
using YanZhiwei.DotNet4.UtilitiesTests.Models;
namespace YanZhiwei.DotNet4.Utilities.Common.Tests
{
    [TestClass()]
    public class QueryableHelperTests
    {
        static List<Person> PersonList = null;
        [TestInitialize]
        public void InitTestDb()
        {
            PersonList = new List<Person>();
            for (short i = 1; i < 6; i++)
            {
                PersonList.Add(new Person() { Age = i, Name = string.Format("YanZhiwei{0}", i) });
            }
        }
        [TestMethod()]
        public void OrderByTest()
        {
            var _actual = PersonList.AsQueryable().OrderBy(p => p.Name, true).ToList();
            Assert.AreEqual(_actual[0].Name, "YanZhiwei5");
            Assert.AreEqual(_actual[0].Age, 5);
        }
    }
}
